﻿<%@ WebHandler Language="C#" Class="update" %>

using System;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.SessionState;

public class update : IHttpHandler, IRequiresSessionState
{

    sqlhelp sql = new sqlhelp();
    result result = new result();
    string str = "";

    public void ProcessRequest(HttpContext context)
    {
        try
        {
            if (context.Session["comid"] == null)
            {
                result.code = "-1";
                result.msg = "用户未登录";
                unit.send(context, result);
                return;
            }

            string Sno = "";//	序号
            string Type = "";//	类型
            string name = "";//	标题
            string text = "";//	内容
            string text1 = "";//	内容1
            string text2 = "";//	内容2
            string text3 = "";//	内容3
            string text4 = "";//	内容4
            string text5 = "";//	内容5
            string number = "";//	数量
            string height = "";//	高度
            string url = "";//	视频地址
            string auto_play = "";//	自动播放
            string img = "";//	视频截图
            string showFontType = "";//	字体大小
            string banner = "";//	banner
            string time = "";//	时间
            string Show = "";


            if (context.Request["Sno"] != null)
            {
                Sno = context.Request["Sno"].ToString();
            }
            else
            {
                result.code = "0";
                result.msg = "未传递Sno";
                unit.send(context, result);
                return;
            }

            if (context.Request["Type"] != null)
            {
                Type = context.Request["Type"].ToString();
            }
            else
            {
                result.code = "0";
                result.msg = "未传递Type";
                unit.send(context, result);
                return;
            }
            
            if (context.Request["name"] != null)
            {
                name = context.Request["name"].ToString();
            }
            else
            {
                result.code = "0";
                result.msg = "未传递name";
                unit.send(context, result);
                return;
            }

            if (context.Request["text"] != null)
            {
                text = context.Request["text"].ToString();
            }
            else
            {
                result.code = "0";
                result.msg = "未传递text";
                unit.send(context, result);
                return;
            }
            if (context.Request["text1"] != null)
            {
                text1 = context.Request["text1"].ToString();
            }
            else
            {
                result.code = "0";
                result.msg = "未传递text1";
                unit.send(context, result);
                return;
            }
            if (context.Request["text2"] != null)
            {
                text2 = context.Request["text2"].ToString();
            }
            else
            {
                result.code = "0";
                result.msg = "未传递text2";
                unit.send(context, result);
                return;
            }

            if (context.Request["text3"] != null)
            {
                text3 = context.Request["text3"].ToString();
            }
            else
            {
                result.code = "0";
                result.msg = "未传递text3";
                unit.send(context, result);
                return;
            }
            if (context.Request["text4"] != null)
            {
                text4 = context.Request["text4"].ToString();
            }
            else
            {
                result.code = "0";
                result.msg = "未传递text4";
                unit.send(context, result);
                return;
            }
            if (context.Request["text5"] != null)
            {
                text5 = context.Request["text5"].ToString();
            }
            else
            {
                result.code = "0";
                result.msg = "未传递text5";
                unit.send(context, result);
                return;
            }

            if (context.Request["number"] != null)
            {
                number = context.Request["number"].ToString();
            }
            else
            {
                result.code = "0";
                result.msg = "未传递number";
                unit.send(context, result);
                return;
            }
            if (context.Request["height"] != null)
            {
                height = context.Request["height"].ToString();
            }
            else
            {
                result.code = "0";
                result.msg = "未传递height";
                unit.send(context, result);
                return;
            }

            if (context.Request["url"] != null)
            {
                url = context.Request["url"].ToString();
            }
            else
            {
                result.code = "0";
                result.msg = "未传递url";
                unit.send(context, result);
                return;
            }
            if (context.Request["auto_play"] != null)
            {
                auto_play = context.Request["auto_play"].ToString();
            }
            else
            {
                result.code = "0";
                result.msg = "未传递auto_play";
                unit.send(context, result);
                return;
            }

            if (context.Request["img"] != null)
            {
                img = context.Request["img"].ToString();
            }
            else
            {
                result.code = "0";
                result.msg = "未传递img";
                unit.send(context, result);
                return;
            }
            if (context.Request["showFontType"] != null)
            {
                showFontType = context.Request["showFontType"].ToString();
            }
            else
            {
                result.code = "0";
                result.msg = "未传递showFontType";
                unit.send(context, result);
                return;
            }

            if (context.Request["banner"] != null)
            {
                banner = context.Request["banner"].ToString();
            }
            else
            {
                result.code = "0";
                result.msg = "未传递banner";
                unit.send(context, result);
                return;
            }
            if (context.Request["time"] != null)
            {
                time = context.Request["time"].ToString();
            }
            else
            {
                result.code = "0";
                result.msg = "未传递time";
                unit.send(context, result);
                return;
            }

            if (context.Request["show"] != null)
            {
                Show = context.Request["show"].ToString();
            }
            else
            {
                result.code = "0";
                result.msg = "未传递Show";
                unit.send(context, result);
                return;
            }





            bool _result = addData(Sno, Type, name, text, text1, text2, text3, text4, text5, number, height, url, auto_play, img, showFontType, banner, time, Show,context.Session["comid"].ToString());
           if (_result)
           {
               result.code = "1";
               result.msg = "";
           }
           else {
               result.code = "0";
               result.msg = "添加失败";
           }
            
            

        }
        catch (Exception e1)
        {
            result.code = "0";
            result.msg = e1.Message;
        }
        unit.send(context, result);
    }

    public bool addData(string Sno,string Type,string	name,string	text,string	text1,string	text2,string	text3,string	text4,string	text5,string	number,string	height,string	url,string	auto_play, string	img,string	showFontType,string	banner,string	time,string Show,string MainId)
    {
        bool result = false;
        string Id = Guid.NewGuid().ToString();
       

        string sql1 = "";
        string sql2 = "";

        if (Sno != "")
        {
            sql1 = sql1 + "Sno,";
            sql2 = sql2 + "" + Sno + ",";
        }
        if (Type != "")
        {
            sql1 = sql1 + "Type,";
            sql2 = sql2 + "" + Type + ",";
        }
        if (name != "")
        {
            sql1 = sql1 + "name,";
            sql2 = sql2 + "'" + name + "',";
        }
        if (text != "")
        {
            sql1 = sql1 + "text,";
            sql2 = sql2 + "'" + text + "',";
        }
        if (text1 != "")
        {
            sql1 = sql1 + "text1,";
            sql2 = sql2 + "'" + text1 + "',";
        }
        if (text2 != "")
        {
            sql1 = sql1 + "text2,";
            sql2 = sql2 + "'" + text2 + "',";
        }
        if (text3 != "")
        {
            sql1 = sql1 + "text3,";
            sql2 = sql2 + "'" + text3 + "',";
        }
        if (text4 != "")
        {
            sql1 = sql1 + "text4,";
            sql2 = sql2 + "'" + text4 + "',";
        }
        if (text5 != "")
        {
            sql1 = sql1 + "text5,";
            sql2 = sql2 + "'" + text5 + "',";
        }
        if (number != "")
        {
            sql1 = sql1 + "number,";
            sql2 = sql2 + "" + number + ",";
        }
        if (height != "")
        {
            sql1 = sql1 + "height,";
            sql2 = sql2 + "" + height + ",";
        }
        if (url != "")
        {
            sql1 = sql1 + "url,";
            sql2 = sql2 + "'" + url + "',";
        }
        if (auto_play != "")
        {
            sql1 = sql1 + "auto_play,";
            sql2 = sql2 + "'" + auto_play + "',";
        }
        if (img != "")
        {
            sql1 = sql1 + "img,";
            sql2 = sql2 + "'" + img + "',";
        }
        if (showFontType != "")
        {
            sql1 = sql1 + "showFontType,";
            sql2 = sql2 + "'" + showFontType + "',";
        }
        if (banner != "")
        {
            sql1 = sql1 + "banner,";
            sql2 = sql2 + "'" + banner + "',";
        }
        if (time != "")
        {
            sql1 = sql1 + "time,";
            sql2 = sql2 + "'" + time + "',";
        }

        if (Show != "")
        {
            sql1 = sql1 + "Show,";
            sql2 = sql2 + "'" + Show + "',";
        }
        
        
        string str = "insert into SYS_WebDetail(Id,MainId," + sql1 + "CreateTime,Enable) values('" + Id + "','" + MainId + "'," + sql2 + "'" + DateTime.Now.ToString() + "',1)";

        
        if (sql.ExecuteNonQuery(str) > 0) {
            result = true;
        }                
        return result;
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}